import {
	defineConfig
} from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

import AutoImport from "unplugin-auto-import/vite"
// https://vitejs.dev/config/
export default defineConfig({
	resolve: {
		// https://cn.vitejs.dev/config/#resolve-alias
		alias: {
			// 设置路径
			'~': path.resolve(__dirname, './'),
			// 设置别名
			'@': path.resolve(__dirname, './src')
		},
		// https://cn.vitejs.dev/config/#resolve-extensions
		extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
	},
	plugins: [
		vue(),
		AutoImport({
			imports: ["vue", "vue-router", "pinia"],
		})
	],
	server: {
		port: '3000',
		proxy: {
			'/api': {
				target: 'http://api.ziyouliulan.top',
				changeOrigin: true,
				rewrite: (path) => path.replace(/^\/api/, '') // 不可以省略rewrite
			}
		}
	},
	base:'./'
})
